package com.fantastic.service.zjs.impl;

import com.fantastic.common.exception.enums.RespStatusInfo;
import com.fantastic.common.exception.sql.DeleteException;
import com.fantastic.common.exception.sql.InsertException;
import com.fantastic.common.exception.sql.SelectException;
import com.fantastic.common.exception.sql.UpdateException;
import com.fantastic.common.utils.IsEmptyUtils;
import com.fantastic.mapper.zjs.VarietySetMealMapper;
import com.fantastic.model.pojo.zjs.VarietySetMeal;
import com.fantastic.service.zjs.VarietySetMealService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: rxx
 * @since: 2024/6/1 15:39
 * @description: 菜品信息和套餐信息关联表service层接口实现类
 */
@Service
public class VarietySetMealServiceImpl implements VarietySetMealService {

    @Resource
    private VarietySetMealMapper varietySetMealMapper;

    /**
     * 查询菜品信息和套餐信息关联表
     *
     * @param varietyMeal
     * @return
     */
    @Override
    public List<VarietySetMeal> listVarietyMeal(VarietySetMeal varietyMeal) {
        List<VarietySetMeal> varietySetMeals = varietySetMealMapper.listVarietyMeal(varietyMeal);
        IsEmptyUtils.listIsEmpty(new SelectException(RespStatusInfo.SELECT_NULL), varietySetMeals);
        return varietySetMeals;
    }

    /**
     * 查询单个菜品信息和套餐信息关联表
     *
     * @param varietyMealId
     * @return
     */
    @Override
    public VarietySetMeal getVarietyMeal(Integer varietyMealId) {
        VarietySetMeal varietySetMeals = varietySetMealMapper.getVarietyMeal(varietyMealId);
        IsEmptyUtils.objectIsNull(new SelectException(RespStatusInfo.SELECT_NULL), varietySetMeals);
        return varietySetMeals;
    }

    /**
     * 添加菜品信息和套餐信息关联表
     *
     * @param varietyMeal
     * @return
     */
    @Override
    public Integer insertVarietyMeal(VarietySetMeal varietyMeal) {
        IsEmptyUtils.integerIsEmpty(new InsertException(RespStatusInfo.DATA_ERROR), varietyMeal.getMealId(), varietyMeal.getVarietyId());
        return varietySetMealMapper.insertVarietyMeal(varietyMeal);
    }

    /**
     * 修改菜品信息和套餐信息关联表
     *
     * @param varietyMeal
     * @return
     */
    @Override
    public Integer updateVarietyMeal(VarietySetMeal varietyMeal) {
        IsEmptyUtils.integerIsEmpty(new UpdateException(RespStatusInfo.DATA_ERROR), varietyMeal.getVarietyMealId(), varietyMeal.getMealId(), varietyMeal.getVarietyId());
        return varietySetMealMapper.updateVarietyMeal(varietyMeal);
    }

    /**
     * 删除菜品信息和套餐信息关联表
     *
     * @param varietyMealId
     * @return
     */
    @Override
    public Integer deleteVarietyMeal(Integer varietyMealId) {
        IsEmptyUtils.integerIsEmpty(new DeleteException(RespStatusInfo.DATA_ERROR), varietyMealId);
        return varietySetMealMapper.deleteVarietyMeal(varietyMealId);
    }
}
